package com.zdy.today.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.daimajia.numberprogressbar.NumberProgressBar;
import com.zdy.today.R;


public class TipDialog extends BaseDialog{

    private String TAG = TipDialog.class.getSimpleName();

    private TextView mMessageTxt;

    public NumberProgressBar getNumber_progress_bar() {
        return number_progress_bar;
    }

    private NumberProgressBar number_progress_bar;

    public TipDialog(Context context) {
        super(context);
        initDialog();
    }

    private void initDialog() {
        View msgView = View.inflate(getContext(), R.layout.dialog_single_message, null);
        mMessageTxt = (TextView) msgView.findViewById(R.id.txt_dialog_content);
        number_progress_bar = (NumberProgressBar) msgView.findViewById(R.id.number_progress_bar);
        setContent(msgView);
    }

    public TipDialog setMessage(String contentMsg){
        if(!TextUtils.isEmpty(contentMsg)){
            mMessageTxt.setText(contentMsg);
        }else{
            mMessageTxt.setVisibility(View.GONE);
        }
        return this;
    }

    /**
     * 对外开放的创建tip的对话框，可直接调用，然后仅仅需要在返回的结果中设置它的一个回调方法即可
     * @param context
     * @param message
     * @return
     */
    public static TipDialog createTipDialog(Context context, String title, String message){
        final TipDialog dialog = new TipDialog(context);
        dialog.setMessage(message).setTitleText(title);
        dialog.setOnCancelListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        return dialog;
    }

}
